from django.db import models


# 商城商品菜单模型
class StoreMenu(models.Model):
    id = models.AutoField(primary_key=True)
    menu_name = models.CharField(max_length=50)
    parent_id = models.IntegerField(default=0)

    def to_dict(self):
        res = {
            "id": self.id,
            "menu_name": self.menu_name,
            "parent_id": self.parent_id
        }
        return res

    @staticmethod
    def get_fields():
        return [
            {"field": "id", "remark": "ID"},
            {"field": "menu_name", "remark": "分类名称", "is_query": "1"},
            {"field": "parent_id", "remark": "父级分类", "type": "select"},
        ]

    class Meta:
        db_table = "store_menu"
        app_label = "models"
